#pragma once
#include "CDependencyObject.h"
#include "CXcpList.h"
#include "CStoryboard.h"
#include "REQUEST.h"


class CVisualState;
class CFrameworkElement;
class CVisualStateCollection;
class CControl;
class CVisualTransitionCollection;

class CVisualStateGroup :
	public CDependencyObject
{

private: 
	CVisualStateGroup(CCoreServices * pCore);
private: 
	static HRESULT GenerateStoryboardKey(CStoryboard *, XUINT32, XUINT16 *, XUINT32 *);
protected: 
	virtual ~CVisualStateGroup();
	virtual HRESULT EnterImpl(CDependencyObject * pNamescopeOwner, struct EnterParams params);
	virtual HRESULT LeaveImpl(CDependencyObject * pNamescopeOwner, struct LeaveParams params);
public: 
	static HRESULT Create(CDependencyObject * * ppObject, CREATEPARAMETERS * pCreate);
	virtual XUINT32 GetTypeIndex() const;
	virtual HRESULT AddEventListener(CDependencyProperty * pdp, CValue * pValue, XINT32 iListenerType, CValue * pResult, XINT32 fHandledEventsToo);
	virtual HRESULT RemoveEventListener(CDependencyProperty * pdp, CValue * pValue);
	HRESULT GetCurrentVisualState(CVisualState * * ppVisualState);
	HRESULT SetCurrentVisualState(CVisualState * pVisualState);
	HRESULT FindStateByName(const XUINT16 * pStateName, CVisualState * * ppVisualState);
	HRESULT StartNewThenStopOld(CFrameworkElement * pControl, XINT32 cNewStoryboards, CStoryboard * * rgNewStoryboards);
	CXcpList<CStoryboard> & GetCurrentlyRunningStoryboards();
	enum VisualStateGroupEvent
	{
		VisualStateEventChanging = 0x0,
		VisualStateEventChanged = 0x1
	};

public: 
	HRESULT NotifyVisualStateEvent(CVisualState * pOldState, CVisualState * pNewState, enum CVisualStateGroup::VisualStateGroupEvent EventState, CControl * pControl);
	static HRESULT EnsureStoryboardSafeForStart(CFrameworkElement * pControl, CStoryboard * pSB);
	CVisualStateCollection * m_pVisualStates;
	CVisualTransitionCollection * m_pTransitions;
private:
	CVisualState * m_pCurrentState;
private: 
	CXcpList<CStoryboard> m_CurrentlyRunningStoryboards;
private: 
	CXcpList<REQUEST> * m_pEventList;

};
